{include file="public/header"}
<body>
<style>
    body{
        margin: 0;
        padding: 0;
    }
    .layui-tree li a cite{
        font-size: 16px;
        line-height: 150%;
    }
   
</style>

<!--显示组织架构图-->
<ul id="demo1"></ul>

{include file="public/footer"}
<script>
//Demo
layui.use(['tree', 'layer'], function(){
  var layer = layui.layer,
  $ = layui.jquery; 
  var params  = {
        url : "{:url('Agent/agent')}",
        data: '',
        type: 'get',
        sCallback:function(res){
             layui.tree({
                elem: '#demo1' //指定元素
                ,target: '_blank' //是否新选项卡打开（比如节点返回href才有效）
                ,click: function(item){ //点击节点回调
                     if(typeof(item.children)=="undefined"){
                         layer.open({
                            content:'该代理商没有下级',
                            icon:2,
                            title : '错误提示',
                        });
                     }else{
                        url="{:url('Trade/index')}"+"?agent="+item.name+"&id="+item.chnlId+"&level="+item.level;
                        location.href = url;
                     }
                   
                    
                }
                ,nodes: res.data
            });
        }
    }
    common.request(params);
 

  
});
</script>
<script type='text/javascript'>
    

  

</script>

</body>
</html>